import Vue from 'vue'
import store from "@/store";

export default function () {
    Vue.directive('has', {
        inserted: function (el, binding) {
            if (!permissionJudge(binding.value)) {
                el.parentNode.removeChild(el);
            }

            function permissionJudge(value) {
                let list = store.state.userButtons;
                for (let item of list) {
                    if (item === value) {
                        return true;
                    }
                }
                return false;
            }
        }
    });
}